package com.baturu.vin.honda.dal.dao;

import com.baturu.vin.honda.dto.HondaPartsMappingDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * 本田主名映射DAO
 * @author jiangxinlei
 */
public interface HondaPartsMappingDAO {

    @Select({"<script>SELECT DISTINCT partsCode, btrPartsName from honda_parts_mapping",
            "WHERE btrPartsName IN",
            "<foreach item ='btrPartsName' index='index' collection='btrPartsNames' open='(' separator=',' close=')'> ",
                "#{btrPartsName}",
            "</foreach>",
            "</script>"})
    List<HondaPartsMappingDTO> findPartsMappingByPartsName(@Param("btrPartsNames") Set<String> btrPartsNames);

    @Select({"<script>select distinct partsCode, btrPartsName from honda_parts_mapping",
            "where partsCode in ",
            "<foreach item='item' index='index' collection='partsCodes' open='(' separator=',' close=')' >",
            "#{item}",
            "</foreach>",
            "</script>"})
    List<HondaPartsMappingDTO> getByPartsCode(@Param("partsCodes") Collection<String> partsCodes);

    @Select({"<script>SELECT DISTINCT parts_id, parts_code, btr_parts_name from honda_parts_mapping_v2",
            "WHERE btr_parts_name IN",
            "<foreach item ='btrPartsName' index='index' collection='btrPartsNames' open='(' separator=',' close=')'> ",
            "#{btrPartsName}",
            "</foreach>",
            "AND dir_list = #{npl}",
            "</script>"})
    List<HondaPartsMappingDTO> findV2PartsMappingByPartsName(@Param("btrPartsNames") Set<String> btrPartsNames, @Param("npl") String npl);

}
